﻿#include"Thread_pool.h"
#include<iostream>

void add(int a, int b)
{
	int z = a + b;
	cout << "z=" << z << endl;
	this_thread::sleep_for(chrono::seconds(2));
}
int add1(int a, int b)
{
	int z = a + b;
	this_thread::sleep_for(chrono::seconds(2));
	return z;
}

int main()
{
	//thread t(add, 12, 34);
	Thread_pool pool;
	vector<future<int>>result;
	for (int i = 0; i < 10; i++)
	{
		//auto obj=bind(add, i, i*2);
		//pool.add_task(obj);
		result.emplace_back(pool.add_task(add1, i, i * 2));
	}
	for (auto& item : result)
	{
		cout << "线程执行结果：" << item.get() << endl;
	}
	//getchar();
	cout << "主线程：" << this_thread::get_id() << endl;
	return 0;
}
